package org.springframework.samples.mvc.basic.edinicamerka;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.mvc.basic.business.AbstractBusinessService;
import org.springframework.samples.mvc.basic.business.Transformer;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.proba.annotations.EdinicaMerkaDAO;
import com.proba.annotations.GenericDAO;
import com.proba.annotations.pojo.EdinicaMerka;

@Service
public class EdinicaMerkaBusinessServiceImpl extends AbstractBusinessService<EdinicaMerka, EdinicaMerkaView> implements EdinicaMerkaBusinessService {
	
	@Autowired
	private EdinicaMerkaDAO edinicaMerkaDao;
	
	private EdinicaMerkaTransformer transformer = new EdinicaMerkaTransformer();

	@PreAuthorize("hasRole('ROLE_DELETE')")
	@Override
	@Transactional
	public List<EdinicaMerkaView> findAll(int startIndex, int pageSize,
			EdinicaMerkaView queryInfo) {
		return transform(edinicaMerkaDao.findByFilterParams(startIndex, pageSize, queryInfo.getId(), queryInfo.getEdinicaMerka(), queryInfo.getEdinicaMerkaLabel()));
	}

	@Override
	protected GenericDAO<EdinicaMerka, Long> getDao() {
		return edinicaMerkaDao;
	}

	@Override
	protected Transformer<EdinicaMerka, EdinicaMerkaView> getTransformer() {
		return transformer;
	}

}
